package com.fjp.heartguard.app.weight

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import com.fjp.heartguard.R

/**
 *Author:Mr'x
 *Time:2024/11/1
 *Description:
 */
class QuestionProgressLayout(context: Context, attrs: AttributeSet) : LinearLayoutCompat(context, attrs) {
    lateinit var pb: ProgressBar
    lateinit var voiceIv: ImageView
    lateinit var curIndexTv: TextView

    init {
        LayoutInflater.from(context).inflate(R.layout.layout_question_progress, this);
        pb = findViewById(R.id.pb)
        voiceIv = findViewById(R.id.voiceIv)
        curIndexTv = findViewById(R.id.curIndexTv)


    }

    fun setValue(value: Int, maxValue: Int,hasVoice:Boolean) {
        val showValue = value * 1f / maxValue * 100
        curIndexTv.setText("${value}/${maxValue}")
        pb.progress = showValue.toInt()
        if(!hasVoice){
            voiceIv.setBackgroundResource(R.drawable.voice_not)
        }

    }


}